package days3.middle.title189;

/**
 * @Author fengzihao
 * @Date 2024-04-17 16:05
 */
class Solution {
    // public static void main(String[] args) {
    //     int[] nums = {1,2};
    //     int k = 3;
    //     rotate(nums,k);
    //     System.out.println(Arrays.toString(nums));
    // }
    public  void rotate(int[] nums, int k) {
        if(k>=nums.length)
            k=k%nums.length;
        int[] auxiliaryArray = new int[k];
        for (int i = 0; i < k; i++) {
            auxiliaryArray[i]=nums[nums.length-k+i];
        }
        for (int i = nums.length - k-1; i >= 0; i--) {
            nums[i+k] = nums[i];
        }
        for (int i = 0; i < k; i++) {
            nums[i]= auxiliaryArray[i];
        }
    }
}
